define([
    'jquery',
    'baseUtils',
    'base',
    'msgTool',
    'plugins/bootstrap-table/bootstrap-table',
    "plugins/bootstrap-dialog/bootstrap-dialog",
    "css!global/plugins/bootstrap-dialog/bootstrap-dialog.css",
    'css!global/plugins/fileInput/fileinput.min.css',
    'plugins/fileInput/fileinput.min'
], function ($, baseUtils, base, msgTool, _, BootstrapDialog) {
    //默认加载基础库
    base();


    return {
        index: function () {
            console.log("index.js。。。。。");
        },
        transact: function () {


            var myTable = $('#transactList');
            var tableRefresh = function () {
                myTable.bootstrapTable('refresh', {url: '/user/search'})
            };

            //table当前行的响应事件
            window.operateEvents = {
                'click .invalid': function (e, value, row) {
                    $.baseUtils.oneInvalid({
                        row: row,
                        tableName: myTable,
                        onText: '作废',
                        offText: '作废',
                        nameText: '办件信息',
                        nameValue: row.itemName,
                        url: '/user/invalid/action'
                    });
                },
                'click .detail': function (e, value, row) {        //审核
                    window.location.href = "details?lawsuitId="+ row.id +'&site=apply_handle'
                },
            };


            //table表格
            myTable.bootstrapTable({
                url: 'transactList.json', // 接口 URL 地址
                cache: false, // 不缓存
                striped: true, // 隔行加亮
                pagination: true, // 开启分页功能
                sidePagination: 'server',//服务端分页
                sortOrder: 'desc', // 设置排序为反序 desc
                fixedColumns: true,//自动修复
                queryParams: queryParams,//搜索附加参数
                smartDisplay: false, // 智能显示 pagination 和 cardview 等
                toolbar: ".toolBar", //顶部工具菜单
                toolbarAlign: "right", //顶部工具位置
                // mobileResponsive: "true", //手机模式自适应宽度（自动变成卡片模式）
                columns: [
                    {
                        field: 'plaintiffName',
                        title: '原告姓名',
                        align: 'left',
                        width: '40%'
                    },  {
                        field: 'createTime',
                        title: '操作时间',
                        align: 'center',
                        width: '25%',
                        formatter: function (value, row, index) {
                            return "创建：" + value + "<br />编辑：" + value;
                        }
                    }, {
                        field: 'itemStatusText',
                        title: '申请状态',
                        align: 'center',
                        width: '10%',
                        formatter: function (value, row, index) {
                            value = row.stage;
                            if (value === 0) {
                                return "<span class=\"label label-warning\"><i class=\"fa fa-lock\" aria-hidden=\"true\"></i>&nbsp;已提交</span>";
                            } else if (value === 1) {
                                return "<span class=\"label label-success\"><i class=\"fa fa-retweet\" aria-hidden=\"true\"></i>&nbsp;审核中</span>";
                            } else if (value === 2) {
                                return "<span class=\"label label-primary\"><i class=\"fa fa-reply\" aria-hidden=\"true\"></i>&nbsp;已办结</span>";
                            } else if (value === 3) {
                                return "<span class=\"label label-danger\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i>&nbsp;已退回</span>";
                            } else {
                                return "<span class=\"label label-inverse\">未知</span>";
                            }
                        }
                   }
                    , {
                        field: 'action',
                        title: '操作',
                        align: 'center',
                        width: '25%',
                        formatter: operateFormatter,
                        events: operateEvents
                    }
                ]
            });


            //搜索刷新
            $('#search').on('click', function () {
                tableRefresh();
            });

            //搜索参数传递
            function queryParams(params) {
                params.search = $(".searchValue").val().trim();
                return {
                    limit: params.limit,
                    offset: params.offset,
                    plaintiffCardNumber: params.search
                };
            }

            //回显
            function responseHandler(res) {
                return res.rows;
            }
        },
        windowOffices: function () {


            var myTable = $('#windowOfficesList');
            var tableRefresh = function () {
                myTable.bootstrapTable('refresh', {url: 'windowOfficesList.json'})
            };

            //table当前行的响应事件
            window.operateEvents = {
                'click .invalid': function (e, value, row) {
                    $.baseUtils.oneInvalid({
                        row: row,
                        tableName: myTable,
                        onText: '作废',
                        offText: '作废',
                        nameText: '一窗多办信息',
                        nameValue: row.itemName,
                        url: '/windowMultipleOffices/invalid'
                    });
                }
            };


            //table表格
            myTable.bootstrapTable({
                url: 'windowOfficesList.json', // 接口 URL 地址
                cache: false, // 不缓存
                striped: true, // 隔行加亮
                pagination: true, // 开启分页功能
                sidePagination: 'server',//服务端分页
                sortOrder: 'desc', // 设置排序为反序 desc
                fixedColumns: true,//自动修复
                queryParams: queryParams,//搜索附加参数
                smartDisplay: false, // 智能显示 pagination 和 cardview 等
                toolbar: ".toolBar", //顶部工具菜单
                toolbarAlign: "right", //顶部工具位置
                //   mobileResponsive: "true", //手机模式自适应宽度（自动变成卡片模式）
                columns: [
                    {
                        field: 'itemName',
                        title: '申请事项',
                        align: 'center'
                    }, {
                        field: 'orgName',
                        title: '处理部门',
                        align: 'center'
                    }, {
                        field: 'createTime',
                        title: '创建时间',
                        align: 'center'
                    }, {
                        field: 'applyStatus',
                        title: '申请状态',
                        align: 'center',
                        formatter: function (value) {
                            var result = null;
                            switch (value) {
                                case 1:
                                    result = "<span class=\"text text-primary\">审核中</span>";
                                    break;
                                case 2:
                                    result = "<span class=\"text text-success\">审核通过</span>";
                                    break;
                                case 3:
                                    result = "<span class=\"text text-danger\">审核拒绝</span>";
                                    break;
                                case 4:
                                    result = "<span class=\"text text-warning\">作废</span>";
                                    break;
                                default:
                                    result = "<span class=\"text text-primary\">未知</span>";
                                    break;
                            }
                            return result;
                        }

                    }, {
                        field: 'action',
                        title: '操作',
                        align: 'center',
                        formatter: operateFormatter,
                        events: operateEvents
                    }
                ]
            });


            //搜索刷新
            $('#search').on('click', function () {
                tableRefresh();
            });

            //搜索参数传递
            function queryParams(params) {
                return {
                    limit: params.limit,
                    offset: params.offset
                };
            }

            //回显
            function responseHandler(res) {
                return res.rows;
            }
        },

        suggestion: function () {


            var myTable = $('#suggestionList');
            var tableRefresh = function () {
                myTable.bootstrapTable('refresh', {url: 'suggestionList.json'})
            };

            //table当前行的响应事件
            window.operateEvents = {
                'click .invalid': function (e, value, row) {
                    $.baseUtils.oneInvalid({
                        row: row,
                        tableName: myTable,
                        onText: '作废',
                        offText: '作废',
                        nameText: '一窗多办信息',
                        nameValue: row.itemName,
                        url: '/suggestion/invalid'
                    });
                }
            };


            //table表格
            myTable.bootstrapTable({
                url: 'suggestionList.json', // 接口 URL 地址
                cache: false, // 不缓存
                striped: true, // 隔行加亮
                pagination: true, // 开启分页功能
                sidePagination: 'server',//服务端分页
                sortOrder: 'desc', // 设置排序为反序 desc
                fixedColumns: true,//自动修复
                queryParams: queryParams,//搜索附加参数
                smartDisplay: false, // 智能显示 pagination 和 cardview 等
                toolbar: ".toolBar", //顶部工具菜单
                toolbarAlign: "right", //顶部工具位置
                //   mobileResponsive: "true", //手机模式自适应宽度（自动变成卡片模式）
                columns: [
                    {
                        field: 'row',
                        title: '序号',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    }, {
                        field: 'orgName',
                        title: '处理部门',
                        align: 'center'
                    }, {
                        field: 'content',
                        title: '内容',
                        align: 'center'
                    }, {
                        field: 'type',
                        title: '类型',
                        align: 'center',
                        formatter: function (value) {
                            var result = null;
                            switch (value) {
                                case 1:
                                    result = "<span class=\"text text-primary\">投诉</span>";
                                    break;
                                case 2:
                                    result = "<span class=\"text text-success\">建议</span>";
                                    break;
                                default:
                                    result = "<span class=\"text text-primary\">未知</span>";
                                    break;
                            }
                            return result;
                        }

                    }, {
                        field: 'createTime',
                        title: '创建时间',
                        align: 'center'
                    }
                ]
            });


            //搜索刷新
            $('#search').on('click', function () {
                tableRefresh();
            });

            //搜索参数传递
            function queryParams(params) {
                return {
                    limit: params.limit,
                    offset: params.offset
                };
            }

            //回显
            function responseHandler(res) {
                return res.rows;
            }
        },

        receive: function () {
            var API_URL = "receive/api.json";
            var myTable = $('#receiveList');
            var tableRefresh = function () {
                myTable.bootstrapTable('refresh', {url: API_URL})
            };

            //table表格
            myTable.bootstrapTable({
                url: API_URL, // 接口 URL 地址
                cache: false, // 不缓存
                striped: true, // 隔行加亮
                pagination: true, // 开启分页功能
                sidePagination: 'server',//服务端分页
                sortOrder: 'desc', // 设置排序为反序 desc
                fixedColumns: true,//自动修复
                queryParams: queryParams,//搜索附加参数
                smartDisplay: false, // 智能显示 pagination 和 cardview 等
                toolbar: ".toolBar", //顶部工具菜单
                toolbarAlign: "right", //顶部工具位置
                //mobileResponsive: "false", //手机模式自适应宽度（自动变成卡片模式）
                columns: [
                    {
                        field: 'itemTypeValue',
                        title: '事项类型'
                    },
                    {
                        field: 'itemName',
                        title: '事项名称',
                        width: '30%'
                    },
                    {
                        field: 'issueDatetime',
                        title: '发证时间',
                        align: 'center'
                    },
                    {
                        field: 'receiveUserName',
                        title: '领取人',
                        align: 'center'
                    }, {
                        field: 'receiveDatetime',
                        title: '领取时间',
                        align: 'center'
                    }, {
                        field: 'receiveStatus',
                        title: '领取状态',
                        align: 'center',
                        width: '10%',
                        formatter: function (value) {
                            if (value === 1) {
                                return "<span class=\"label label-primary\"><i class=\"fa fa-lock\" aria-hidden=\"true\"></i>&nbsp;已领取</span>";
                            } else {
                                return "<span class=\"label label-danger\"><i class=\"fa fa-lock\" aria-hidden=\"true\"></i>&nbsp;待领取</span>";
                            }
                        }
                    }
                ]
            });

            //搜索刷新
            $('#search').on('click', function () {
                tableRefresh();
            });

            //搜索参数传递
            function queryParams(params) {
                params.search = $(".searchValue").val().trim();
                return {
                    limit: params.limit,
                    offset: params.offset,
                    search: params.search
                };
            }

            //回显
            function responseHandler(res) {
                return res.rows;
            }

        },
        info: function () {

        },
        settings: function () {
            //上传
            $.baseUtils.uploader({
                filesType: "#imagesUploader",
                showCaption: "头像",
                browseLabel: "选择头像",
                uploadLabel: "上传"
            }).on("fileuploaded", function (event, data) {
            });

        }

    };
});
